//
//  RiskyCollector.swift
//  DemoUI
//
//  Created by 白瑾浩 on 2022/4/7.
//

import Foundation
//演员模型
actor SafeCollector {
    var deck: Set<String>

    init(deck: Set<String>) {
        self.deck = deck
    }

    func send(card selected: String, to person: SafeCollector) async-> Bool {
        guard deck.contains(selected) else { return false }

        deck.remove(selected)
        await person.transfer(card: selected)
        return true
    }

    func transfer(card: String) {
        deck.insert(card)
    }
}

//class RiskyCollector {
//    var deck: Set<String>
//
//    init(deck: Set<String>) {
//        self.deck = deck
//    }
//
//    func send(card selected: String, to person: RiskyCollector) -> Bool {
//        guard deck.contains(selected) else { return false }
//
//        deck.remove(selected)
//        person.transfer(card: selected)
//        return true
//    }
//
//    func transfer(card: String) {
//        deck.insert(card)
//    }
//}
